//获得装备时的爆炸效果

cc.Class({
    extends: cc.Component,

    properties: {

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

        this.ParticleGather = this.node.getChildByName('Particle Gather')
        this.ParticleExplode = this.node.getChildByName('Particle Explode')

        this.ParticleExplode.getComponent(cc.ParticleSystem).duration = 1.8

        this.explodeDuration = this.ParticleExplode.getComponent(cc.ParticleSystem).duration
        this.explodeTime = 0 
        this.logoPic = this.node.getChildByName('logoPic')
        this.exploding = false
        this.Shine = this.node.getComponent('Shine')
        this.Shake = this.node.getComponent('Shake')

        this.Shake.shake(9999)
        
    },

    explode() {
        this.Shake.stop()
        this.Shine.shine()
        
        this.ParticleGather.active =false
        this.ParticleExplode.active = true
        this.exploding = true  
    },

    easeExpOut (t,b,c,d){
        return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
    },

    update (dt) {
        if(this.exploding &&  this.explodeDuration > this.explodeTime){
            this.explodeTime += dt
            let radius = this.easeExpOut(this.explodeTime, 0,300,0.5)
            this.ParticleExplode.getComponent(cc.ParticleSystem).startRadius =radius
            this.ParticleExplode.getComponent(cc.ParticleSystem).endRadius =radius +5
        }
    },
});
